package itdep.common.context.spring;

import org.springframework.security.acls.model.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Ivan Khalopik
 * @version $Revision: 4 $ $Date: 2010-06-10 13:13:16 +0000 (Thu, 10 Jun 2010) $
 */
public class DynamicAclService implements AclService {
	private final SecurityChecker securityChecker;

	public DynamicAclService(final SecurityChecker securityChecker) {
		this.securityChecker = securityChecker;
	}

	@Override
	public List<ObjectIdentity> findChildren(final ObjectIdentity parentIdentity) {
		return null;
	}

	@Override
	public Acl readAclById(final ObjectIdentity object) throws NotFoundException {
		return new DynamicAcl(object, securityChecker);
	}

	@Override
	public Acl readAclById(final ObjectIdentity object, final List<Sid> sids) throws NotFoundException {
		return readAclById(object);
	}

	@Override
	public Map<ObjectIdentity, Acl> readAclsById(final List<ObjectIdentity> objects) throws NotFoundException {
		final Map<ObjectIdentity, Acl> result = new HashMap<ObjectIdentity, Acl>();
		for (ObjectIdentity object : objects) {
			result.put(object, readAclById(object));
		}
		return result;
	}

	@Override
	public Map<ObjectIdentity, Acl> readAclsById(final List<ObjectIdentity> objects, final List<Sid> sids) throws NotFoundException {
		return readAclsById(objects);
	}
}
